package com.example.campus.mapper;

import com.example.campus.pojo.entity.Like;
import com.example.campus.pojo.vo.UserLikeVO;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface LikeMapper {

    @Delete("delete from `like` where info_id = #{infoId}")
    void deleteByInfoId(Long infoId);

    @Delete("delete from `like` where id = #{id}")
    void deleteById(Long id);

    @Insert("insert into `like`(user_id, info_id, create_time) values (#{userId}, #{infoId}, #{createTime})")
    void insert(Like like);

    @Delete("delete from `like` where info_id = #{infoId} and user_id = #{userId}")
    void deleteByInfoIdAndUserId(Long infoId, Long userId);

    List<Like> getLikeList(Like like);

    @Select("select count(*) from `like` where info_id = #{infoId}")
    Integer getLikeCount(Long infoId);

    @Select("select count(*) from `like`")
    Long getLikeTotal();
}
